package com.car.advertising.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.car.advertising.R;
import com.car.advertising.entity.IncomeEntity;
import com.support.widget.layout.adapter.BaseRecyclerViewAdapter;
import com.support.widget.layout.holder.BaseViewHolder;

import java.util.List;

/**
 * 开发者：LuoYi
 * Time: 2017 14:51 2017/5/3 05
 */

public class IncomeDetailsAdapter extends BaseRecyclerViewAdapter<IncomeEntity.SignList, BaseViewHolder> {

    public IncomeDetailsAdapter(Context context, List<IncomeEntity.SignList> strings) {
        super(context, strings);
    }

    public void setRefreshList(List<IncomeEntity.SignList> strings) {
        this.mDatas = strings;
        notifyDataSetChanged();
    }

    @Override
    protected void bindView(BaseViewHolder holder, int position, IncomeEntity.SignList model) {
        IncomeHolder incomeHolder = (IncomeHolder) holder;
        incomeHolder.timeTv.setText(model.getSignDate());
        incomeHolder.houstonTv.setText("+ ¥" + model.getProfit());
        incomeHolder.explainTv.setText(model.getTaskName());
    }

    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_income_details, parent, false);
        return new IncomeHolder(mContext, view, this);
    }

    class IncomeHolder extends BaseViewHolder {

        public TextView timeTv;
        public TextView houstonTv;
        public TextView explainTv;

        public IncomeHolder(Context context, View rootView, BaseRecyclerViewAdapter mBaseRecyclerViewAdapter) {
            super(context, rootView, mBaseRecyclerViewAdapter);
            timeTv = (TextView) rootView.findViewById(R.id.item_income_time_tv);
            houstonTv = (TextView) rootView.findViewById(R.id.item_income_houston_tv);
            explainTv = (TextView) rootView.findViewById(R.id.item_income_explain_tv);
        }
    }
}
